package com.lxmap;

import javax.swing.text.html.HTMLDocument;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class hashmapdemo02 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("御龙骑士","尹志平");
        map.put("标枪选手","马超");
        map.put("人物挂件","明世隐");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        entries.forEach(new Consumer<Map.Entry<String, String>>() {
            @Override
            public void accept(Map.Entry<String, String> stringStringEntry) {
                String key = stringStringEntry.getKey();
                String value = stringStringEntry.getValue();
                System.out.println(key+value);
            }
        });
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+value);
        }
        Iterator<Map.Entry<String, String>> it = entries.iterator();
        while(it.hasNext())
        {
            Map.Entry<String, String> next = it.next();
            String key = next.getKey();
            String value = next.getValue();
            System.out.println(key+"  "+value);
        }
    }
}
